var gridList;
$(document).ready(function () {
    gridList = mini.get("datagrid");
    gridList.load({});
});

function formatOper(e) {
    var row = e.record;
    return"<a class='mini-button' hideFocus='' href='javascript:void(0)' onClick='editData(\""+e.value+"\")'><span class='mini-button-text  mini-button-icon icon-edit'>修改</span></a><span class='separator'></span>" +
        "<a class='mini-button' hideFocus='' href='javascript:void(0)' onClick='addZone(\""+e.value+"\")'><span class='mini-button-text  mini-button-icon icon-filter'>授权</span></a><span class='separator'></span>" +
        "<a class='mini-button' hideFocus='' href='javascript:void(0)' onClick='addpreview(\""+e.value+"\")'><span class='mini-button-text  mini-button-icon icon-search'>预览</span></a><span class='separator'></span>" +
        "<a class='mini-button' hideFocus='' href='javascript:void(0)' onClick='removeData(\""+e.value+"\",\""+row.portalTitle+"\")'><span class='mini-button-text  mini-button-icon icon-remove'>删除</span></a>";
}

function addZone(obj) {
    mini.open({
        url: bootPATH + "../portal/portalapplicationzone.html?rowid=" + obj + "&temp=" + new Date().getMilliseconds(),
        title: "Portal授权", width: 1000, height: 650,
        onload: function () {
            //给对话框传参数！
            var iframe = this.getIFrameEl();
        },
        ondestroy: function (e) {
            if (e && e != 'close') {

            }
        }
    });
}

function addpreview(obj) {
    mini.open({
        url: bootPATH + "../portal/portaltemplate_preview.html?rowid=" + obj + "&temp=" + new Date().getMilliseconds(),
        title: "Portal预览", width: 1000, height: 650,
        onload: function () {
            //给对话框传参数！
            var iframe = this.getIFrameEl();
        },
        ondestroy: function (e) {
            if (e && e != 'close') {

            }
        }
    });
}

function addData() {
    window.top.windowtab.addTab("新增Portal模板", "base/sysPortal/sysPortalEdit.html?type=new&tabID=" + encodeURIComponent(window.top.windowtab.getCurrentSelectTabID()) + "&temp=" + new Date().getMilliseconds());
}

function editData(obj) {
    window.top.windowtab.addTab("修改Portal模板", "base/sysPortal/sysPortalEdit.html?rowid=" + obj + "&tabID=" + encodeURIComponent(window.top.windowtab.getCurrentSelectTabID()) + "&temp=" + new Date().getMilliseconds());
}

function removeData(rowid, title) {
    mini.confirm("您确定要删除'" + title + "'吗？", "", function (e) {
        if (e == "ok") {
            ActHttpRequest('sysPortal!del.do?id=' + rowid, {}, function (data) {
                if (data.OK == "OK") {
                    gridList.load({});
                } else {
                    mini.alert(data.msg);
                }
            },null,null,null,'删除中。。。',true);
        }
    });
}

function CallBackFun(data) {
    gridList.load({});
}